<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <script src="${pageContext.request.contextPath}/common/js/jquery-1.7.2.min.js" type="text/javascript"></script>    
    
<link rel="stylesheet" href="${pageContext.request.contextPath}/common/style/login.css" type="text/css" media="screen" />
<script> 
$(function(){
$("#name").focus();
});
		function loginFormSubmit() {

			var name=$("#name").val();
			var pwd=$("#password").val();
			$("#msg").html("");
			if(name==""){
			alert("用户名不能为空");
			return;
			}
			if(pwd==""){
			alert("密码不能为空");
			return;
			}
			$.ajax({
				type: "post",
				url: "${pageContext.request.contextPath}/login.action",
				dataType:'json',
				data:"name="+name+"&pwd="+pwd,
				success:function(data,textStatus){
					var result = data;
					if(result.success){
						top.window.location.href="${pageContext.request.contextPath}/panel/index.jsp";
					}else{
						if(result.msg==1)
						{
							$("#msg").html("该用户不存在！");
							$("#name").focus();
						}
						if(result.msg==2)
						{
							$("#msg").html("密码不正确！");
							$("#pwd").focus();
						}
					}
				}
			});
		
		}
		 $(document).keydown(function(event){ 
    		 if(event.keyCode == 13) 
    		 {
    			 loginFormSubmit();
        	}
    	 });

	</script>

</head>
  
  <body onload="if(top!=window) top.location.href=window.location.href">
<div id="box">
<div id="loginbox">
	<div id="center">
	<div id="head"><img src="${pageContext.request.contextPath}/common/images/login01.jpg"/></div>
	<div id="body">
		<ul>
			<li id="left"></li>
			<li id="middle">
			<form>
			
			<div class="use info">用户<input class="useinfo" type="text" name="name" id="name"value="youzipan"/></div>
			<div class="use password">密码<input class="useinfo" type="password" name="password" id="password" value="123456"/></div>
			<div><img style="cursor:pointer;" onclick="loginFormSubmit();" src="${pageContext.request.contextPath}/common/images/login.gif"/></div><span id="msg"></span>
				</form>
			</li>
			
		</ul>
	</div>
	<div id="bottom"><img src="${pageContext.request.contextPath}/common/images/login05.jpg"/></div>
	</div>
</div> 
</div>
</body>
</html>
